package org.example.fanruan;

import com.sun.scenario.effect.Merge;
import sun.security.provider.MD5;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;

/**
 * @author Yyming
 * @version 10.0
 * Created by Yyming on 2020/7/8
 */
public class MergeArray {

    public static void main(String[] args) throws NoSuchAlgorithmException, IOException {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        in.nextToken();
        int m = (int) in.nval;
        int[] num1 = new int[m];
        for (int i = 0; i < m; i++) {
            in.nextToken();
            num1[i] = (int) in.nval;
        }
        in.nextToken();
        int n = (int) in.nval;
        int[] merge = new int[m+n];
        int index = 0;
        for (int i = 0; i < n; i++) {
            in.nextToken();
            int temp = (int) in.nval;
            while (index < m && num1[index] < temp ){
                merge[index + i] = num1[index];
                index++;
            }
            merge[index + i] = temp;
        }
        for (int i = index; i < m; i++) {
            merge[n + index] = num1[index];
        }
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(Arrays.toString(merge).getBytes());
        byte[] md5s = md5.digest();
        System.out.println(new BigInteger(1,md5s).toString(16));
    }
}
